if __name__ == '__main__':
    import json
    from pprint import pprint
    classes = ["bike","bus","car","motor","person","rider","traffic light","traffic sign","train","truck"]
    a = open("/data1/zyx/yks/sources/Detectron/output/bdd_testB_multiscales/results_1539356739.34.txt", "rt")
    lst_file = "/data1/zyx/yks/dataset/bdd100k/testB/testb.lst"
    img_lst = [x.strip() for x in open(lst_file, "rt")]
    print(len(img_lst))
    all_results = []
    for line in a:
        name, x0, y0, x1, y1, score, cls = line.strip().split("\t")
        name = name.strip().split("/")[-1]
        if name[:-4] in img_lst:
            obj = {"category": classes[int(cls)-1],
                   "timestamp": 1000,
                   "score": float(score),
                   "name": name,
                   "bbox": [float(x0), float(y0), float(x1), float(y1)]}
            all_results.append(obj)
            # pprint(obj)
    json.dump(all_results, open("det_testB_multi_scales.json", "wt"))